<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="common/include :: header('客户列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
        <div class="gray-bg">
            <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="post-form">
                    <div class="select-list">
                        <ul>
                            <li>
                                客户名字：<input type="text" name="name"/>
                            </li>
                            <li>
                                客户电话：<input type="text" name="phone"/>
                            </li>
                            <li>
                                客户状态：
                                <select name="name">
                                    <option value="">所有</option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
            </div>
        </div>
        <div lass="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:post:add">
                <i class="fa fa-plus"></i> 新增
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:post:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:post:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:post:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
        </div>
</div>
        <th:block th:include="common/include :: footer" />
        <script th:inline="javascript">
            var prefix = ctx + "/system/customer";
            $(function () {
                // 表格的属性
                var options = {
                    url: prefix + "/query",   //查询数据的请求
                    createUrl: prefix + "/addPage",  //点击新增跳转的地址
                    updateUrl: prefix + "/editPage?id={id}", //点击编辑跳转的地址
                    removeUrl: prefix + "/remove", //点击删除跳转的地址
                 //   exportUrl: prefix + "/export", // 数据导出请求的地址
                 //   sortName: "age",   //后台根据什么字段进行排序
                    modalName: "客户", //模态框名称
                    columns: [{
                        checkbox: true
                    },
                        {
                            field: 'id',
                            title: '客户id',
                        },
                        {
                            field: 'name',
                            title: '客户名称',
                            sortable: true  //是否允许排序
                        },

                        {
                            field: 'phone',
                            title: '客户电话',
                            sortable: true
                        },
                        {
                            field: 'age',
                            title: '客户年龄',
                            sortable: true
                        },
                        {
                            title: '操作',
                            align: 'center',
                            formatter: function(value, row, index) {
                                var actions = [];
                                actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" ' +
                                    'onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                                actions.push('<a class="btn btn-danger btn-xs '+ '" href="javascript:void(0)"' +
                                    ' onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        //        actions.push('<a class="btn btn-success btn-xs" onclick="$.operate.edit('+row.id+')"><i class="fa fa-edit"></i>编辑</a>')
                                return actions.join('');
                            }
                        }]
                };
                $.table.init(options);
            })
        </script>
</body>
</html>